package com.xiaotu.PoolDemo;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author xiaotu
 * @Description //TODO
 * @Date 2022/3/30 16:26
 * @ClassName TestPool
 * @Version 1.0
 * 测试线程池
 **/
public class TestPool {
    public static void main(String[] args) {
        //创建服务创建线程池
        ExecutorService threadPool = Executors.newFixedThreadPool(10);
        //执行
        threadPool.execute(new MyThRun());
        threadPool.execute(new MyThRun());
        threadPool.execute(new MyThRun());
        threadPool.execute(new MyThRun());
        threadPool.execute(new MyThRun());
        //关闭连接
        threadPool.shutdown();
    }
}
class MyThRun implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"====>"+i+"<===");
        }
    }
}
